package examples.computations;

import org.apache.commons.functor.UnaryFunction;

import util.DiffComputation;
import util.Int;
import util.functors.AccociBinaryOP;
import util.functors.BinaryOperator;

public class MPS extends DiffComputation<Int, Int, Int> {

	public MPS() {
		init = new Int(0);

		oplus = new AccociBinaryOP<Int>() {
			@Override
			public Int evaluate(Int left, Int right) {
				return new Int(Math.max(left.get(), right.get()));
			}

			@Override
			public Int id() {
				return new Int(Integer.MIN_VALUE);
			}
		};

		otimes = new AccociBinaryOP<Int>() {

			@Override
			public Int evaluate(Int left, Int right) {
				return new Int(left.get() + right.get());
			}

			@Override
			public Int id() {
				return new Int(0);
			}

		};

		g = new UnaryFunction<Int, Int>() {
			@Override
			public Int evaluate(Int obj) {
				return new Int(Math.max(0, obj.get()));
			}

		};

		p = new BinaryOperator<Int, Int, Int>() {

			@Override
			public Int evaluate(Int x, Int c) {

				return c;

			}

			@Override
			public Int getInstanceOfT0() {
				return new Int(0);
			}

		};

		q = new UnaryFunction<Int, Int>() {
			@Override
			public Int evaluate(Int da) {
				return da;
			}

		};
	}

}
